package com.xmotor.test_singleton_mode;

public class Client {
    private String domain;
    private String api;

    private Client(String domain, String api) {
        this.domain = domain;
        this.api = api;
    }

    // volatile禁止指令重排
    private static volatile Client client = null;

    public static Client getInstance(String domain, String api){
        if (client == null){
            synchronized (Client.class){
                if (client == null){
                    client = new Client(domain, api);
                }
            }
        }
        return client;
    }

}
